package com.ruoyi.system.domain;

import com.ruoyi.common.utils.CalcUtil;
import com.ruoyi.system.service.IAlpStageActualService;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 合同表管理对象 alp_contract_detail
 * 
 * @author zhangjun
 * @date 2020-02-13
 */
public class AlpContractDetail extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键id */
    private Long contractId;

    /** 合同编号 */
    @Excel(name = "合同编号")
    private String contractNo;

    /** 合同名称 */
    @Excel(name = "合同名称")
    private String contractName;

    /** 销售负责人id */
    @Excel(name = "销售负责人id")
    private String xsPrincipalId;

    /** 销售负责人 */
    @Excel(name = "销售负责人")
    private String xsPrincipalName;

    /** 交付负责人id */
    @Excel(name = "交付负责人id")
    private String jfPrincipalId;

    /** 交付负责人 */
    @Excel(name = "交付负责人")
    private String jfPrincipalName;

    /** 甲方名称 */
    @Excel(name = "甲方名称")
    private String partyAName;

    /** 中标方 */
    @Excel(name = "中标方")
    private String biddingCompany;

    /** 中标时间 */
    @Excel(name = "中标时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date biddingTime;

    /** 投标时间 */
    @Excel(name = "投标时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date tenderTime;

    /** 公示结束期 */
    @Excel(name = "公示结束期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date publicityTime;

    /** 预算提交日期 */
    @Excel(name = "预算提交日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date budgetSubmissionTime;

    /** 是否通过招投标 */
    @Excel(name = "是否通过招投标")
    private Integer passTender;

    /** bidding金额 */
    @Excel(name = "bidding金额")
    private BigDecimal biddingMoney;

    /** 项目类型一 */
    @Excel(name = "项目类型一")
    private String projectTypeOne;

    /** 项目类型二 */
    @Excel(name = "项目类型二")
    private String projectTypeTwo;

    /** 行业 */
    @Excel(name = "行业")
    private String industry;

    /** 客户 */
    @Excel(name = "客户")
    private String customer;

    /** 地域 */
    @Excel(name = "地域")
    private String territory;

    /** 交付二级部门 */
    @Excel(name = "交付二级部门")
    private String jfDepartment;

    /** 销售二级部门 */
    @Excel(name = "销售二级部门")
    private String xsDepartment;

    /** 合同预计签订时间 */
    @Excel(name = "合同预计签订时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date contractsignedBudgetTime;

    /** 合同所属年度 */
    @Excel(name = "合同所属年度")
    private Integer contractInyear;

    /** 合同签订年度 */
    @Excel(name = "合同签订年度")
    private Integer contractSignedInyear;

    /** bidding所属年度 */
    @Excel(name = "bidding所属年度")
    private Integer biddingInyear;

    /** 销售组CCM */
    @Excel(name = "销售组CCM")
    private String salesCcm;

    /** 客户简称 */
    @Excel(name = "客户简称")
    private String customerShort;

    /** 是否有中标通知书 */
    @Excel(name = "是否有中标通知书")
    private Integer hasbidwinNotice;

    /** 是否签订合同 */
    @Excel(name = "是否签订合同")
    private Integer hassignContract;

    /** 合同签订时间 */
    @Excel(name = "合同签订时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date contractSignTime;

    /** booking金额 */
    @Excel(name = "booking金额")
    private BigDecimal booking;
	
	 /** 第二负责人id */
    @Excel(name = "第二负责人id")
    private String xsPrincipal2Id;

    /** 第二负责人 */
    @Excel(name = "第二负责人")
    private String xsPrincipal2Name;

    /** 收款单位 */
    @Excel(name = "收款单位")
    private String payee;

    /** 20年初合同余额 */
    @Excel(name = "20年初合同余额")
    private BigDecimal balanceSince2020;

    /** 合同余额 */
    @Excel(name = "合同余额")
    private BigDecimal balance;

    /** 终验时间 */
    @Excel(name = "终验时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date finialAcceptanceTime;
	
	    /** 回款条件 */
    @Excel(name = "回款条件")
    private String paymentCondition;

    /** 合同金额 */
    @Excel(name = "合同金额")
    private BigDecimal contractMoney;

    /** 已回款金额 */
    @Excel(name = "已回款金额")
    private BigDecimal hasReceivedMoney;

    /** 未回款金额 */
    @Excel(name = "未回款金额")
    private BigDecimal notReceivedMoney;

    /** 已回款比例 */
    @Excel(name = "已回款比例")
    private String hasReceivedRate;

    //0代表 正常，   1 代表删除
    private String delFlag;

    private Long userId;

    private Long deptId;

	/** 合同阶段 */
    private List<AlpContractStage> alpContractStages;

    public List<AlpContractStage> getAlpContractStages() {
        return alpContractStages;
    }

    public void setAlpContractStages(List<AlpContractStage> alpContractStages) {
        this.alpContractStages = alpContractStages;
    }

    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public void setContractId(Long contractId)
    {
        this.contractId = contractId;
    }

    public Long getContractId() 
    {
        return contractId;
    }
    public void setContractNo(String contractNo) 
    {
        this.contractNo = contractNo;
    }

    public String getContractNo() 
    {
        return contractNo;
    }
    public void setContractName(String contractName) 
    {
        this.contractName = contractName;
    }

    public String getContractName() 
    {
        return contractName;
    }
    public void setXsPrincipalId(String xsPrincipalId) 
    {
        this.xsPrincipalId = xsPrincipalId;
    }

    public String getXsPrincipalId() 
    {
        return xsPrincipalId;
    }
    public void setXsPrincipalName(String xsPrincipalName) 
    {
        this.xsPrincipalName = xsPrincipalName;
    }

    public String getXsPrincipalName() 
    {
        return xsPrincipalName;
    }
    public void setJfPrincipalId(String jfPrincipalId) 
    {
        this.jfPrincipalId = jfPrincipalId;
    }

    public String getJfPrincipalId() 
    {
        return jfPrincipalId;
    }
    public void setJfPrincipalName(String jfPrincipalName) 
    {
        this.jfPrincipalName = jfPrincipalName;
    }

    public String getJfPrincipalName() 
    {
        return jfPrincipalName;
    }
    public void setPartyAName(String partyAName) 
    {
        this.partyAName = partyAName;
    }

    public String getPartyAName() 
    {
        return partyAName;
    }
    public void setBiddingCompany(String biddingCompany) 
    {
        this.biddingCompany = biddingCompany;
    }

    public String getBiddingCompany() 
    {
        return biddingCompany;
    }
    public void setBiddingTime(Date biddingTime) 
    {
        this.biddingTime = biddingTime;
    }

    public Date getBiddingTime() 
    {
        return biddingTime;
    }
    public void setTenderTime(Date tenderTime) 
    {
        this.tenderTime = tenderTime;
    }

    public Date getTenderTime() 
    {
        return tenderTime;
    }
    public void setPublicityTime(Date publicityTime) 
    {
        this.publicityTime = publicityTime;
    }

    public Date getPublicityTime() 
    {
        return publicityTime;
    }
    public void setBudgetSubmissionTime(Date budgetSubmissionTime) 
    {
        this.budgetSubmissionTime = budgetSubmissionTime;
    }

    public Date getBudgetSubmissionTime() 
    {
        return budgetSubmissionTime;
    }
    public void setPassTender(Integer passTender) 
    {
        this.passTender = passTender;
    }

    public Integer getPassTender() 
    {
        return passTender;
    }
    public void setBiddingMoney(BigDecimal biddingMoney) 
    {
        this.biddingMoney = biddingMoney;
    }

    public BigDecimal getBiddingMoney() 
    {
        return biddingMoney;
    }
    public void setProjectTypeOne(String projectTypeOne) 
    {
        this.projectTypeOne = projectTypeOne;
    }

    public String getProjectTypeOne() 
    {
        return projectTypeOne;
    }
    public void setProjectTypeTwo(String projectTypeTwo) 
    {
        this.projectTypeTwo = projectTypeTwo;
    }

    public String getProjectTypeTwo() 
    {
        return projectTypeTwo;
    }
    public void setIndustry(String industry) 
    {
        this.industry = industry;
    }

    public String getIndustry() 
    {
        return industry;
    }
    public void setCustomer(String customer) 
    {
        this.customer = customer;
    }

    public String getCustomer() 
    {
        return customer;
    }
    public void setTerritory(String territory) 
    {
        this.territory = territory;
    }

    public String getTerritory() 
    {
        return territory;
    }
    public void setJfDepartment(String jfDepartment) 
    {
        this.jfDepartment = jfDepartment;
    }

    public String getJfDepartment() 
    {
        return jfDepartment;
    }
    public void setXsDepartment(String xsDepartment) 
    {
        this.xsDepartment = xsDepartment;
    }

    public String getXsDepartment() 
    {
        return xsDepartment;
    }
    public void setContractsignedBudgetTime(Date contractsignedBudgetTime) 
    {
        this.contractsignedBudgetTime = contractsignedBudgetTime;
    }

    public Date getContractsignedBudgetTime() 
    {
        return contractsignedBudgetTime;
    }
    public void setContractInyear(Integer contractInyear) 
    {
        this.contractInyear = contractInyear;
    }

    public Integer getContractInyear() 
    {
        return contractInyear;
    }
    public void setContractSignedInyear(Integer contractSignedInyear) 
    {
        this.contractSignedInyear = contractSignedInyear;
    }

    public Integer getContractSignedInyear() 
    {
        return contractSignedInyear;
    }
    public void setBiddingInyear(Integer biddingInyear) 
    {
        this.biddingInyear = biddingInyear;
    }

    public Integer getBiddingInyear() 
    {
        return biddingInyear;
    }
    public void setSalesCcm(String salesCcm) 
    {
        this.salesCcm = salesCcm;
    }

    public String getSalesCcm() 
    {
        return salesCcm;
    }
    public void setCustomerShort(String customerShort) 
    {
        this.customerShort = customerShort;
    }

    public String getCustomerShort() 
    {
        return customerShort;
    }
    public void setHasbidwinNotice(Integer hasbidwinNotice) 
    {
        this.hasbidwinNotice = hasbidwinNotice;
    }

    public Integer getHasbidwinNotice() 
    {
        return hasbidwinNotice;
    }
    public void setHassignContract(Integer hassignContract) 
    {
        this.hassignContract = hassignContract;
    }

    public Integer getHassignContract() 
    {
        return hassignContract;
    }
    public void setContractSignTime(Date contractSignTime) 
    {
        this.contractSignTime = contractSignTime;
    }

    public Date getContractSignTime() 
    {
        return contractSignTime;
    }
    public void setBooking(BigDecimal booking) 
    {
        this.booking = booking;
    }

    public BigDecimal getBooking() 
    {
        return booking;
    }
	public void setXsPrincipal2Id(String xsPrincipal2Id) 
    {
        this.xsPrincipal2Id = xsPrincipal2Id;
    }

    public String getXsPrincipal2Id() 
    {
        return xsPrincipal2Id;
    }
    public void setXsPrincipal2Name(String xsPrincipal2Name) 
    {
        this.xsPrincipal2Name = xsPrincipal2Name;
    }

    public String getXsPrincipal2Name() 
    {
        return xsPrincipal2Name;
    }
    public void setPayee(String payee) 
    {
        this.payee = payee;
    }

    public String getPayee() 
    {
        return payee;
    }
    public void setBalanceSince2020(BigDecimal balanceSince2020) 
    {
        this.balanceSince2020 = balanceSince2020;
    }

    public BigDecimal getBalanceSince2020() 
    {
        return balanceSince2020;
    }
    public void setBalance(BigDecimal balance) 
    {
        this.balance = balance;
    }

    public BigDecimal getBalance() 
    {
        return balance;
    }
    public void setFinialAcceptanceTime(Date finialAcceptanceTime) 
    {
        this.finialAcceptanceTime = finialAcceptanceTime;
    }

    public Date getFinialAcceptanceTime() 
    {
        return finialAcceptanceTime;
    }
    public void setPaymentCondition(String paymentCondition) 
    {
        this.paymentCondition = paymentCondition;
    }

    public String getPaymentCondition() 
    {
        return paymentCondition;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public BigDecimal getContractMoney() {
        if (null != booking) {
            contractMoney = booking;
        }
        if (null != biddingMoney) {
            contractMoney =  biddingMoney;
        }
        return contractMoney;
    }

    public void setContractMoney(BigDecimal contractMoney) {
        this.contractMoney = contractMoney;
    }

    public BigDecimal getHasReceivedMoney() {
        if (hasReceivedMoney == null) {
            return BigDecimal.ZERO;
        }
        return hasReceivedMoney;
    }

    public void setHasReceivedMoney(BigDecimal hasReceivedMoney) {
        this.hasReceivedMoney = hasReceivedMoney;
    }

    public BigDecimal getNotReceivedMoney() {
        if (null != getContractMoney()) {
            notReceivedMoney = getContractMoney().subtract(getHasReceivedMoney());
        }
        return notReceivedMoney;
    }

    public void setNotReceivedMoney(BigDecimal notReceivedMoney) {
        this.notReceivedMoney = notReceivedMoney;
    }

    public String getHasReceivedRate() {
        if (null != getContractMoney()) {
            hasReceivedRate = CalcUtil.calcRate(getHasReceivedMoney(), getContractMoney());
        }
        return hasReceivedRate;
    }

    public void setHasReceivedRate(String hasReceivedRate) {
        this.hasReceivedRate = hasReceivedRate;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("contractId", getContractId())
            .append("contractNo", getContractNo())
            .append("contractName", getContractName())
            .append("xsPrincipalId", getXsPrincipalId())
            .append("xsPrincipalName", getXsPrincipalName())
            .append("jfPrincipalId", getJfPrincipalId())
            .append("jfPrincipalName", getJfPrincipalName())
            .append("partyAName", getPartyAName())
            .append("biddingCompany", getBiddingCompany())
            .append("biddingTime", getBiddingTime())
            .append("tenderTime", getTenderTime())
            .append("publicityTime", getPublicityTime())
            .append("budgetSubmissionTime", getBudgetSubmissionTime())
            .append("passTender", getPassTender())
            .append("biddingMoney", getBiddingMoney())
            .append("projectTypeOne", getProjectTypeOne())
            .append("projectTypeTwo", getProjectTypeTwo())
            .append("industry", getIndustry())
            .append("customer", getCustomer())
            .append("territory", getTerritory())
            .append("jfDepartment", getJfDepartment())
            .append("xsDepartment", getXsDepartment())
            .append("contractsignedBudgetTime", getContractsignedBudgetTime())
            .append("contractInyear", getContractInyear())
            .append("contractSignedInyear", getContractSignedInyear())
            .append("biddingInyear", getBiddingInyear())
            .append("salesCcm", getSalesCcm())
            .append("customerShort", getCustomerShort())
            .append("hasbidwinNotice", getHasbidwinNotice())
            .append("hassignContract", getHassignContract())
            .append("contractSignTime", getContractSignTime())
            .append("booking", getBooking())
            .append("xsPrincipal2Id", getXsPrincipal2Id())
            .append("xsPrincipal2Name", getXsPrincipal2Name())
            .append("payee", getPayee())
            .append("balanceSince2020", getBalanceSince2020())
            .append("balance", getBalance())
            .append("finialAcceptanceTime", getFinialAcceptanceTime())
            .append("paymentCondition", getPaymentCondition())
            .toString();
    }
}
